#include"Thread.h"
#include <stdio.h>

//--------------------------------------------------------
// NAME: Thread
// FUNC:
//--------------------------------------------------------
Thread::Thread(ThreadPriority pri, string _name)
	: priority(pri), name(_name)
{
}

//--------------------------------------------------------
// NAME: ~Thread()
// FUNC:
//--------------------------------------------------------
Thread::~Thread()
{
}

//--------------------------------------------------------
// NAME: start()
// FUNC: Creates the thread.
//--------------------------------------------------------
void Thread::start()
{
	// handle, attr, routine, args)
	pthread_create(&handle, 0, threadMapper, (void*) this);

//	setThreadPriority(handle, priority);
}

//--------------------------------------------------------
// NAME: getName()
// FUNC:
//--------------------------------------------------------
string Thread::getName()
{
	return name;
}

//--------------------------------------------------------
// NAME: setPriority
// FUNC: Attempts to change the Thread's priority to pri.
// RET: true if successful, false otherwise
//--------------------------------------------------------
bool Thread::setPriority(ThreadPriority pri)
{
/*	int policy;
	struct sched_param param;
	int r = pthread_getschedparam(handle, &policy, &param);
	if (r == 0)
	{
		param.sched_priority = pri;
		r = pthread_setschedparam(handle, policy, &param);
	}
	return r == 0;*/
	return 0;
}

//--------------------------------------------------------
// NAME: getPriority
// FUNC:
//--------------------------------------------------------
Thread::ThreadPriority Thread::getPriority()
{
	return priority;
}
